<?php

class Confirmation extends QPanel {

    public $strTitle, $strMessage;
    public $btnConfirm, $btnCancel;

    public function __construct($objParentObject, $strControlId = null, $objConfirmAction = null, $objCancelAction = null) {
        parent::__construct($objParentObject, $strControlId);

        $this->CssClass = 'modal hide';
        $this->SetCustomAttribute('role', 'dialog');

        $this->Template = __DOCROOT__ . __SUBDIRECTORY__ . '/admin/view/shared/confirmation.tpl.php';

        $this->btnConfirm = new QButton($this);
        $this->btnConfirm->Text = QApplication::Translate('Confirm');
        $this->btnConfirm->PrimaryButton = true;

        if ($objConfirmAction)
            $this->btnConfirm->AddAction(new QClickEvent(), $objConfirmAction);

        $this->btnConfirm->AddAction(new QClickEvent(), new QTerminateAction());

        $this->btnCancel = new QButton($this);
        $this->btnCancel->Text = QApplication::Translate('Cancel');
        $this->btnCancel->SetCustomAttribute('data-dismiss', 'modal');

        if ($objCancelAction)
            $this->btnCancel->AddAction(new QClickEvent(), $objCancelAction);

        $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction());
    }

    public function Show() {
        $this->Refresh();
        QApplication::ExecuteJavaScript(sprintf('$j("#%s").modal("show")', $this->ControlId));
    }

    public function Hide() {
        QApplication::ExecuteJavaScript(sprintf('$j("#%s").modal("hide")', $this->ControlId));
    }

    public function Toggle() {
        QApplication::ExecuteJavaScript(sprintf('$j("#%s").modal("toggle")', $this->ControlId));
    }

}

?>